<?php

include(dirname(__FILE__).'/inc/config.php');

include(dirname(__FILE__).'/inc/tree.class.php');

$typelist = dbList('select * from `type001` order by tid asc');

//print_r($typelist);

$tree = new tree();//类实例化为对象
$tree->init( $typelist );//初始化数据  


var_dump( $list =    $tree->get_tree_list( 0 , 15)  );

// selelt * from art where tid in (15,16,7,17,18,8,3);


$html = '';
foreach($list as $k => $v ){

    $html .= "<option value=\"{$v['tid']}\"  {$v['_selected']} > {$v['_prefix']}{$v['typename']}  </option>";

    //$html .= "栏目名：{$v['_prefix']}{$v['typename']}  {$v['_selected']}<br/>";
}

echo '<select>';

echo $html;

echo '</select>';

























die();
//===========================================================

$a = [111,222,333];
print_r($a);
    //print_r($typelist );


    $tree = new tree();
    $tree->init($typelist);


echo '<pre>';
echo '<hr/>';
echo '得到父栏目';
    $getP = $tree->getP(10); 
    var_dump($getP);

echo '<hr/>';
echo '得到父级数组';
    $getPP = $tree->getPP(10); 
    var_dump($getPP);


echo '<hr/>';
echo '得到当前位置数组';
    $getPP = $tree->getPos(10); 
    var_dump($getPP);


echo '<hr/>';
echo '当前位置HTML：';
    $getPP = $tree->getPlace(10); 
    var_dump ($getPP);


echo '<hr/>';
echo '得到子级数组';
    $getC = $tree->getC(10); 
    var_dump($getC);

echo '<hr/>';
echo '获取全部子孙栏目数组';
    var_dump(   $tree->getCC(1) );


echo '<hr/>';
echo '获取全部子孙栏目 ids';
    var_dump(   $ids = $tree->getIds(1) );
    var_dump( " select * from table where tid in ( {$ids}) ");


echo '<hr/>';
echo '获取 同级self 栏目数组';
    var_dump(   $tree->getS(14) );
    //var_dump($tree);


echo '<hr/>';
echo '获取子孙分类 list';
    var_dump(   $tree->getCL() );


echo '<hr/>';
echo '获取每个父分类下的子分类 $tree->getJs()';
    var_dump(   $tree->getJs()  );



echo '<hr/>';
echo '获取每个父分类下的子分类  $tree->getPL() ';
    var_dump(   $tree->getPL()  );

echo '<hr/>';
echo '获取每个父分类下的子分类  $tree->getTree() ';
    var_dump(   $tree->getTree()  );


echo '<hr/>';
echo '获取每个父分类下的子分类  $tree->get_tree_list() ';
echo '</pre>';
    $list =    $tree->get_tree_list( 0 , 0 ) ;
    foreach($list as $k => $v ){
        echo $v['_prefix'] , $v['typename'] , $v['_selected'] ,$v['_deep'], '<br/>';

    }


echo '<hr/>';
echo '<hr/>';
echo '<hr/>';
echo $html = '';
    foreach($list as $k => $v ){
        $html .= "<option value=\"{$v['tid']}\" {$v['_selected']}> {$v['_deep']} {$v['_prefix']}{$v['typename']} (列表)</option>" ;
    }
echo '<select>'.$html.'</select>';
